package cn.imvc.app.jobs;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;

import cn.imvc.app.domains.OrderState;
import cn.imvc.app.entities.StorageOrder;
import cn.imvc.app.models.StorageOrderModel;
@DisallowConcurrentExecution
public class AutomaticReceivingQuarz{
	@Autowired
	StorageOrderModel storageOrderModel;
	/**
	 * 自动收货
	 */
	public void aotoReceving(JobExecutionContext context) {
		List<StorageOrder> storageOrderList = storageOrderModel.findByStateAndReceiptEndTimeLessThan(OrderState.Delivered.getValue(),new Date());
		for (StorageOrder storageOrder : storageOrderList) {
				storageOrderModel.updateAutoReceipt(storageOrder);
		}
		
		System.out.println("自动收货完毕！！！");
		
    }
}
